package org.zuel.huhuForum.component;

import com.alibaba.fastjson.JSONObject;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.zuel.huhuForum.config.RabbitmqConfig;
import org.zuel.huhuForum.param.Event;


@Component
public class SendMsg {
    @Autowired
    private RabbitTemplate rabbitTemplate;

    public void fireEvent(Event event) {
        rabbitTemplate.convertAndSend(RabbitmqConfig.QUEUE_MESSAGE,JSONObject.toJSONString(event));

    }

    public void addEvent(Event event){
        rabbitTemplate.convertAndSend(RabbitmqConfig.DISCUSS_SEARCH_EXCHANGE,"",JSONObject.toJSONString(event));

    }

    public void searchEvent(Event event){
        rabbitTemplate.convertAndSend(RabbitmqConfig.SEARCH_ADD_EXCHANGE,"", JSONObject.toJSONString(event));
    }

    public void mailEvent(Event event){
        rabbitTemplate.convertAndSend(RabbitmqConfig.QUEUE_EMAIL,JSONObject.toJSONString(event));
    }

    public void readEvent(Event event){
        rabbitTemplate.convertAndSend(RabbitmqConfig.QUEUE_READED,JSONObject.toJSONString(event));
    }

    public  void historyEvent(Event event){
        rabbitTemplate.convertAndSend(RabbitmqConfig.QUEUE_HISTORY,JSONObject.toJSONString(event));
    }


}
